package com.waterstudio.filedownloader.ext.m3u8.client;

import android.net.Uri;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import java.io.IOException;

/**
 * Created by chensuilun on 2019/3/23.
 */
public class ClientBuilder {
    private ClientBuilder() {
    }

    @NonNull
    public static Client newClient(@NonNull Uri uri) throws IOException {
        if (uri.getScheme() != null) {
            String scheme = uri.getScheme();
            if (!TextUtils.isEmpty(scheme)) {
                if (scheme.startsWith("http")) {
                    return new Http(uri);
                } else {
                    return new File(uri);
                }
            }
        }
        throw new IOException("Invalid url " + uri.toString());
    }
}
